package com.zye.controller;

import com.alibaba.fastjson2.JSON;
import com.zye.entity.Student;
import com.zye.service.StudentService;
import com.zye.service.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findId")
public class findStudentById extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf-8");
        String id = req.getParameter("id");
        StudentService service = new StudentServiceImpl();
        Student student = service.findStudentById(Integer.parseInt(id));
        String str = JSON.toJSONString(student);
        resp.getWriter().write(str);
    }
}
